<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    
    <title></title>
  	<script type="text/javascript" src="js/jquery-1.8.2.js"></script> 
    <script type="text/javascript" src="js/common.js"></script> 
	<script type="text/javascript" src="js/jquery.form.js"></script>
</head>
  <body>
   <table width="100%" border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td width="17" valign="top" background="images/mail_leftbg.gif"><img src="images/left-top-right.gif" width="17" height="29" /></td>
    <td valign="top" background="images/content-bg.gif"><table width="100%" height="31" border="0" cellpadding="0" cellspacing="0" class="left_topbg" id="table2">
      <tr>
        <td height="31"><div class="titlebt">菜单修改</div></td>
      </tr>
    </table></td>
    <td width="16" valign="top" background="images/mail_rightbg.gif"><img src="images/nav-right-bg.gif" width="16" height="29" /></td>
  </tr>
  <tr>
    <td valign="middle" background="images/mail_leftbg.gif">&nbsp;</td>
    <td valign="top" bgcolor="#F7F8F9">
    	<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
	      <tr>
	        <td colspan="2" valign="top">
	      		<!--  控件按钮栏-->
		         <TABLE class=main_tab id=mainTable cellSpacing=0 cellPadding=0 width=100% border=0>
					<tr>
		                <td>
		                 	 <input type="button" name="menuModifySave"  id="menuModifySave" value="菜单修改保存" onclick="submitForm()">
		                </td>
		             </tr>
			      </TABLE>
		     </td>
		     <td>&nbsp;</td>
		  </tr>
		  <tr>
	        <td height="40" colspan="4">
	        	<table width="100%" height="1" border="0" cellpadding="0" cellspacing="0" bgcolor="#CCCCCC">
			          <tr>
			            <td></td>
			          </tr>
	        	</table>
	        </td>
		  </tr>
		  <tr>
		  	 <td colspan="30">
		  	 <form id="saveMenuForm" action="<%=basePath%>/menuAction_modifyMenu.action"  method="post">
		    		<table class="tab_data"  id="dataTable"  style="height:150px; width:600px;" align="left">  
						  <tr>
						        <td>菜单ID:</td>
							    <td><input type="text"  id="stMenuId"  name="menu.stMenuId"   value="${menu.stMenuId}" readOnly/><font size="5" color="#FF4500">*</font></td>
						  </tr>
					      <tr>
						       	<td> 菜单名称:</td>
						       	<td> <input type="text"  id="stMenuName"  name="menu.stMenuName"   value="${menu.stMenuName}" /><font size="5" color="#FF4500">*</font></td>
						       	<td> 菜单编号: </td>
						       	<td> <input type="text"  id="stMenuNumber"  name="menu.stMenuNumber"   value="${menu.stMenuNumber} "/><font size="5" color="#FF4500">*</font></td>
						  </tr>
						  <tr>
						  		<td>母菜单编号:</td>
						  		<td><input type="text"  id="stPrecNumber"  name="menu.stPrecNumber"   value="${menu.stPrecNumber} "/></td>
						       	<td> 菜单级别:</td>
						       	<td> <input type="text"  id="stMenuLevel"  name="menu.stMenuLevel"  value="${menu.stMenuLevel} " /><font size="5" color="#FF4500">*</font></td>
						  </tr>
						  <tr>
								<td>菜单路径:</td>
								<td><textArea  id="stMenuUrl"  name="menu.stMenuUrl" cols="25" rows="4">${menu.stMenuUrl} </textArea></td>
						       	<td>菜单状态:</td>
						       	<td><select   id="stState"  name="menu.stState">
						       	       <c:choose>
								       	        <c:when test="${menu.stState == 1000 }">
										       	     <option value="1000" selected>有效</option>
										       		 <option value="9999" >无效</option>
									       		 </c:when>
								       		 <c:otherwise>
								       		 	 <option value="1000" >有效</option>
									       		 <option value="9999" selected >无效</option>
								       		 </c:otherwise>
								       </c:choose>
						       	    </select><font size="5" color="#FF4500">*</font>
						       	</td>
						  </tr>
						   <tr>
								<td>菜单备注:</td>
								<td><textArea  id="stRemark" name="menu.stRemark" cols="25" rows="4">${menu.stRemark}</textArea></td>
					       </tr>
				 	</table>
				 	</form>
		        </td>
		  </tr>
		  <!-- 翻页工具  -->
		  <tr>
		     <td colspan="8">
		     </td>
		  </tr>
	      <tr>
	        <td height="40" colspan="4">
	        	<table width="100%" height="1" border="0" cellpadding="0" cellspacing="0" bgcolor="#CCCCCC">
			          <tr>
			            <td></td>
			          </tr>
	        	</table>
	        </td>
	      </tr>
	      <tr>
	        <td width="2%">&nbsp;</td>
	        <td width="51%" class="left_txt"><img src="images/icon-mail2.gif" width="16" height="11"> <br>
	              <img src="images/icon-phone.gif" width="17" height="14"> </td>
	        <td>&nbsp;</td>
	        <td>&nbsp;</td>
	      </tr>
	</table>
    </td>
    <td background="images/mail_rightbg.gif">&nbsp;</td>
</tr>
<tr>
   <td valign="bottom" background="images/mail_leftbg.gif"><img src="images/buttom_left2.gif" width="17" height="17" /></td>
   <td background="images/buttom_bgs.gif"><img src="images/buttom_bgs.gif" width="17" height="17"></td>
   <td valign="bottom" background="images/mail_rightbg.gif"><img src="images/buttom_right2.gif" width="16" height="17" /></td>
</tr>
</table>
<script type="text/javascript">
	function submitForm(){  
		var stMenuId =  document.getElementById("stMenuId").value;  
	    var stMenuName =  document.getElementById("stMenuName").value;  
	    var stMenuNumber =  document.getElementById("stMenuNumber").value.replace(/(^\s*)|(\s*$)/g, ""); 
	    var stPrecNumber =  document.getElementById("stPrecNumber").value.replace(/(^\s*)|(\s*$)/g, "");  
	    var stMenuLevel =  document.getElementById("stMenuLevel").value.replace(/(^\s*)|(\s*$)/g, "");   
	    var stMenuUrl =  document.getElementById("stMenuUrl").value;  
	    var stState =  document.getElementById("stState").value; 
	    var stRemark =  document.getElementById("stRemark").value;  
		      
		var  regNumber=/^[0-9]{4}$/;
		
		document.getElementById("stMenuNumber").value = stMenuNumber;
		document.getElementById("stPrecNumber").value = stPrecNumber;
		document.getElementById("stMenuLevel").value = stMenuLevel;
		
		
		
		if(stMenuId == null || stMenuId == ""){
			alert("菜单ID不能为空");
			return false;
		}
		if(stMenuName == null || stMenuName == ""){
			alert("菜单名不能为空");
			return false;
		}
		if(stMenuNumber == null || stMenuNumber == ""){
			alert("菜单编号不能为空");
			return false;
		}
		
		if(!regNumber.exec(stMenuNumber)){
			alert("菜单编号格式错误");
			return false;
		}
		if(stPrecNumber != null && stPrecNumber !="" ){
			if(!regNumber.exec(stPrecNumber)){
				alert("母菜单格式出错");
				return false;
			}
		}
		
		if(stMenuLevel == null || stMenuLevel == ""){
			alert("菜单等级不能为空");
			return false;
		}
		if((stMenuUrl == null || stMenuUrl == "") && stMenuLevel != "1"){
			alert("菜单路径不能为空");
			return false;
		}
		
		if(stMenuLevel != "1" && (stMenuNumber < stPrecNumber) ){
			alert("菜单级别与菜单编号不符合");
			return false;
		}
		
		  var form = document.getElementById("saveMenuForm");  
		  form.submit();   
    }
</script>

  </body>
</html>
